import os
import time


def decorator(func):
    def wrapper(*args, **kwargs):

        start_time = time.time()
        class_name = None
        print(args)
        print(f'len(args) ------- {len(args)}')
        args = list(args)
        args.append(4)
        args.append(5)
        args.append(6)
        if args:
            class_name = args[0].__class__.__name__
            print(func.__code__.co_varnames)
            func(*args)
        else:
            func()

        end_time = time.time()
        print(end_time - start_time)
        print(class_name)

    return wrapper

def ExceptionHandle(func):
    def wrapper(*args, **kwargs):
        try:
            print('执行了 ExceptionHandle')
            func(*args)
        except Exception as e:
            print(e)
    return wrapper



class Page():

    lst = ['\\', '|', '/', '-']

    @decorator
    @ExceptionHandle
    # @decorator
    def fak(self, a=1, b=2, c=3):
        print(f'a={a} ------ b={b} ------- c={c}')
        print('a')

class g():
    is_c = False

def E(func):
    def wrapper(*args, **kwargs):
        try:
            func(*args)
        except Exception as err:
            print(err, '-'* 100)
            g.is_c = True
        else:
            print('没有错误')

    return wrapper



def D(func):
    def wrapper(*args, **kwargs):

        # li = [1, 0, 1]
        # for i in li:
        try:
            func(**kwargs)
        except Exception as e:
            print(f'{e}')
            # continue
        else:
            print("completed。。。。。。。。。。")

            # if g.is_c:
            #     g.is_c = False
            #     continue

    return wrapper
# @E
@D
def a(i):
    if not i:
        print(1/0)
    if i == 2:
        os._exit(0)
    print('a'.center(100, '-'))

class DESC():

    def DESC(self):
        print('fsajdiofjsiodofjsoaidfjoassijdfifdsjiiiiiiiiiiiiiiiiiiiiiiii')


# @decorator
# def NumSum():
#     res = sum(range(1,1000))
#     print(res)



if __name__ == '__main__':
    # NumSum()
    # p = Page()
    # p.fak()
    a(i=2)
    # DESC().DESC()



